package com.dzsw.netty.basic.future;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class FutureTask {

    public static void main(String[] args) {
        SquareCalculator cal = new SquareCalculator();
        Future<Integer> f = cal.calculate(12);
        try {
            while(!f.isDone()) {
                System.out.println("Calculating...");
                Thread.sleep(1000);
            }
            System.out.println(f.get());
        } catch (InterruptedException e) {
            e.fillInStackTrace();
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
}
